Skip to content

Support gt, ge, lt and le filters on date fields - #98

Merged
paulirwin merged 1 commit into
feature23:mainfrom
danielgreen:fix/date-range-filters
Oct 26, 2026
Merged

paulirwin merged 1 commit into
feature23:mainfrom
danielgreen:fix/date-range-filters

Conversation

@danielgreen

@danielgreen danielgreen commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #101

What was wrong

A range filter on an Edm.DateTimeOffset field returned 400:

POST /indexes/{index}/docs/search
{ "search": "*", "filter": "effective_date ge 2025-01-01T00:00:00Z" }

400: Greater than or equal comparison not supported for type DateTimeOffset

Only eq worked on dates. gt, ge, lt and le all failed.

What changed

Dates are indexed as Unix milliseconds. Each range handler in ODataQueryVisitor now has a date case that compares on that value, as the eq handler already does.

Tests

DateRangeFilterTests (new, 6 tests): each operator against a document dated exactly on the boundary, so the tests show which operators include it; the same instant written with another offset; and a closed range. All 6 fail without the change. All 979 unit tests pass.

Not covered: a comparison with the value first (2025-01-01T00:00:00Z lt effective_date) fails for every field type, not only dates. That is a separate gap.

dotnet test from the repo root currently stops before any test runs, on main too: restoring AzureSearchEmulator.Aspire fails with NU1902, a moderate advisory for MessagePack 2.5.302 (GHSA-qhrr-8q5h-9q3h) that the project treats as an error. I ran the unit and integration test projects directly.

@paulirwin paulirwin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

@paulirwin
paulirwin enabled auto-merge (squash) October 26, 2026 17:28
A range filter on an Edm.DateTimeOffset field, such as
"Updated ge 2025-01-01T00:00:00Z", returned 400 with "comparison not
supported for type DateTimeOffset". Only eq worked.

Dates are indexed as Unix milliseconds, so each range handler now
compares on that, as the eq handler already does.
@paulirwin
paulirwin force-pushed the fix/date-range-filters branch from 6119590 to 0bf71c7 Compare October 26, 2026 17:29
@paulirwin
paulirwin merged commit 24f57ec into feature23:main Oct 26, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Range filters (gt, ge, lt, le) on Edm.DateTimeOffset fields return 400

2 participants